<?

	function writeDateTime($name, $date){
		echo '<select name="'.$name.'" class=inpts>';
		foreach ( $date  as $data ) {
			echo '<option value="';
			echo $data ['VALUE'].'"';
			echo ($data ['SELECTED'] == 1 ? 'selected' : '');
			echo' >';
				echo $data ['NAME'];
			echo '</option>';
		}
	  echo '</select>';
	}

  $frm['gid'] = intval ($frm['gid']);
  $q = 'select * from hl_groups';
  if (!($gsth = mysql_query ($q))) {
    exit (mysql_error ());
  }

  $listings = array ();
  while ($grow = mysql_fetch_array ($gsth)) {
    array_push ($listings, $grow);
  }
  
	?>
<form method=post>
	<input type="hidden" name="a" value="add_listing">
	<input type="hidden" name="action" value="save">
	<input type="hidden" name="gid" value="<?php echo $frm['gid'];?>">
	<input type="hidden" name="p" value="<?php echo $frm['p'];?>">
	<table cellspacing=1 cellpadding=2 border=0 width=100%>
	<tr>
 		<td width=30%>Name:</td>
 		<td><input type="text" name="name" value="" class=inpts size=50></td>
	</tr>
	<tr>
 		<td>Group:</td>
 		<td>
  		<select name="group_id" class=inpts>
  		<?php foreach ($listings as $group) {?>
    		<option value="<?php echo $group['id'];?>" <?php echo ($group['id'] == $frm['gid'] ? 'selected' : '');?> >
    			<?php echo htmlspecialchars ($group['name']);?>
    		</option>
  		<?php }?>
  		</select>
 		</td>
	</tr>
	<tr>
 		<td>Rating:</td>
 		<td>
  		<select name="rating" class=inpts>
	  		<?php for ($i = 0; $i <= 5; ++$i) {?>
	    		<option value=<?php echo $i;?> >
	    			<?php echo $i;?>
	    		</option>
	  		<?php }?>
  		</select>
 	</td>
	</tr>
	<tr>
 		<td>Status:</td>
  	<td>
  		<select name="status" class=inpts>
     		<option value=0>Off</option>
     		<option value=1 selected>On</option>
     		<option value=2>Not Approved</option>
   		</select>
  	</td>
	</tr>
	<tr>
 <td>Paying Status:</td>
  <td>
  	<select name="hyip_status" class=inpts>
    	<option value=1>Paying</option>
     	<option value=2 selected>Waiting</option>
     	<option value=3>Problem</option>
     	<option value=4>Not Paying</option>
   </select>
  </td>
</tr>
<tr>
	<td>URL:</td>
	<td><input type="text" name="url" value="" class=inpts size=50></td>
</tr>
<tr>
 <td>Percents:</td><td><input type="text" name="percents" value="" class=inpts size=50></td>
</tr>
<tr>
      <td>Minimal Spend:</td>
      <td><input type="text" name="min_spend" value="" class=inpts size=50></td>
</tr>
<tr>
      <td>Maximal Spend:</td>
      <td><input type="text" name="max_spend" value="" class=inpts size=50></td>
</tr>
<tr>
 <td>Referral:</td><td><input type="text" name="referral" value="" class=inpts size=50></td>
</tr>
<tr>
 <td>Withdrawal:</td>
 <td><select name="withdrawal_type" class=inpts>
     <option value=1>Manual</option>
     <option value=2>Instant</option>
     <option value=3>Automatic</option>
   </select>
 </td>
</tr>
<tr>
 <td>Contact E-mail:</td>
<td><input type="text" name="email" value="" class=inpts size=50></td>
</tr>
<tr>
 <td>Support E-mail:</td>
<td><input type="text" name="support_email" value="" class=inpts size=50></td>
</tr>

<tr>
 <td>Support Forum (MMG):</td>
<td><input type="text" name="support_forum" value="" class=inpts size=50></td>
</tr>
<tr>
 <td>Support Forum (TG):</td>
<td><input type="text" name="support_form" value="" class=inpts size=50></td>
</tr>

<tr>
 <td>Support Forum (DTM):</td>
<td><input type="text" name="support_aim" value="" class=inpts size=50></td>
</tr>

<tr>
 <td>Support Forum (OWN):</td>
<td><input type="text" name="support_forum_own" value="" class=inpts size=50></td>
</tr>

<tr>
 <td>Added:</td>
	<?php $date = get_date_arrays ('', '', '', 5, 5);?>
	<td>	
	<?php 
		writeDateTime('month', $date ['MONTHS']);
 		writeDateTime('day', $date ['DAYS']);
 		writeDateTime('year', $date ['YEARS']);
	
	?>
	</td>
</tr>

<tr>
 <td>Started:</td>
	<?php $date = get_date_arrays ('', '', '', 5, 5);?>
	<td>	
	<?php 
		writeDateTime('smonth', $date ['MONTHS']);
 		writeDateTime('sday', $date ['DAYS']);
 		writeDateTime('syear', $date ['YEARS']);
	
	?>
	</td>
</tr>


<tr>
	<td>Expires After:</td>
  <td>
  	<input type="text" name="expiration" value="<?php echo htmlspecialchars ($row['expiration']);?>" class=inpts size=10> days (enter '0' to skip limitation)
  </td>
</tr>
<tr>
 <td>Closed:</td>
  <?php $date = get_date_arrays ('0', '0', '0', 5, 5);?>
 <td>
 		<select name="cmonth" class=inpts>
   		<option value=0>-</option>
  		<?php foreach ($date['MONTHS'] as $data) {?>
    	<option value="<?php echo $data['VALUE'];?>" <?php echo ($data['SELECTED'] == 1 ? 'selected' : '');?> ><?php echo $data['NAME'];?> </option>
  		<?php }?>	
  	</select>
  	<select name="cday" class=inpts>
   		<option value=0>-</option>
  		<?php foreach ($date['DAYS'] as $data) {?>
    	<option value="<?php echo $data['VALUE'];?>" <?php echo ($data['SELECTED'] == 1 ? 'selected' : '');?>><?php echo $data['NAME'];?> </option>
  		<?php }?>
  	</select>
  	<select name="cyear" class=inpts>
   		<option value=0>-</option>
  		<?php foreach ($date['YEARS'] as $data) {?>
    		<option value="<?php echo $data['VALUE'];?>" <?php echo ($data['SELECTED'] == 1 ? 'selected' : '');?>> <?php echo $data['NAME'];?> </option>
  		<?php }?>
  	</select>
 </td>
</tr>
<tr>
  <td valign=top>Payment Systems:</td>
  <td>
	  <?php $payments = preg_split ('/\\s*,\\s*/', $settings['payments']);
	  foreach ($payments as $payment) {?>
	    <input type="checkbox" name="payments[<?php echo $payment;?>]" value=1> 
	    <?php echo $payment;?>
	    <br>
	  <?php }?>
  </td>
</tr>
<tr>
	 <td>HYIP E-currency Accounts:<br>
	  	<small>comma sparated</small></td><td><input type="text" name="account" value="" class=inpts size=10>
	 </td>
</tr>
<tr>
 <td>Review:</td><br>
<td><textarea name="support_phone" cols=82 rows=5 class=inpts></textarea></td>
</tr>

<tr>
 <td> Description:</td>
<td><textarea name="description" cols=82 rows=5 class=inpts></textarea></td>
</tr>


<tr>
<tr>
  <td colspan=2><input type="submit" value="Add" class=sbmt></td>
</tr>
</table>
</form>
